package org.clockworkmages.games.anno1186.gui;

import java.io.PrintWriter;
import java.io.StringWriter;

import org.clockworkmages.games.anno1186.GameBeansContext;
import org.clockworkmages.games.anno1186.GameGuiService;

public class GameUiUtil {

	public static void logError(String message) {
		System.out.println(message);
		GameBeansContext
				.getBean(GameGuiService.class)
				.getTextPane()
				.addInfoToBuffer("\n[ERROR]" + message + "\n",
						FontStyleConstants.RED_BOLD);
		System.out.println(message);

	}

	public static void logError(Exception e) {
		StringWriter errors = new StringWriter();
		e.printStackTrace(new PrintWriter(errors));
		logError(errors.toString());
	}

	public static void logError(String message, Exception e) {
		StringWriter errors = new StringWriter();
		e.printStackTrace(new PrintWriter(errors));
		logError(message + "\n" + errors.toString());
	}
}
